package com.buss.core.wrap;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.codehaus.jackson.JsonEncoding;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.ObjectMapper;

public class UserListRwap {


	public static void main(String[] args) throws Exception{
		ObjectMapper mapper = new ObjectMapper();
		JsonGenerator jsonGenerator = mapper.getJsonFactory().createJsonGenerator(System.out,JsonEncoding.UTF8);
		Bean bean = new Bean();
		bean.setId("a");
		bean.setName("测试1");
		bean.setPrice(12f);
		List<Bean> list = new ArrayList<UserListRwap.Bean>();
		list.add(bean);
		bean = new Bean();
		bean.setId("b");
		bean.setName("测试2");
		bean.setPrice(120f);
		list.add(bean);
		bean = new Bean();
		bean.setId("a");
		bean.setName("测试1");
	//	bean.setPrice(12f);
		list.add(bean);
		try {
			jsonGenerator.writeObject(list);
		} catch (JsonProcessingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	static class Bean{
		private String id;
		private String name;
		private float price;
		public String getId() {
			return id;
		}
		public void setId(String id) {
			this.id = id;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public float getPrice() {
			return price;
		}
		public void setPrice(float price) {
			this.price = price;
		}
		
	}	
}
